package com.my.zl.console.controller.autocode;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.my.zl.common.dto.ReqDTO;
import com.my.zl.common.dto.ResDTO;
import com.my.zl.common.dto.advancedQuery.PageQueryDTO;
import com.my.zl.console.common.aop.LogAnnotation;
import com.my.zl.console.controller.base.BaseController;
import com.my.zl.console.entity.autocode.ZlEntity;
import com.my.zl.console.dto.autocode.entity.ReqEntityAddDTO;
import com.my.zl.console.dto.autocode.entity.ReqEntityDelDTO;
import com.my.zl.console.dto.autocode.entity.ReqEntityEditDTO;
import com.my.zl.console.dto.autocode.entity.ReqEntityQueryDTO;
import com.my.zl.console.dto.autocode.entity.ReqEntityDetailDTO;
import com.my.zl.console.dto.autocode.entity.ReqEntityStateDTO;
import com.my.zl.console.dto.autocode.entity.ResEntityAddDTO;
import com.my.zl.console.dto.autocode.entity.ResEntityDelDTO;
import com.my.zl.console.dto.autocode.entity.ResEntityEditDTO;
import com.my.zl.console.dto.autocode.entity.ResEntityQueryDTO;
import com.my.zl.console.dto.autocode.entity.ResEntityDetailDTO;
import com.my.zl.console.service.autocode.IEntityService;
import com.my.zl.console.dto.autocode.entity.ResEntityStateDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 实体配置
 * @author ZL
 */
@Api(value="实体配置",tags ="实体配置")
@RestController
@RequestMapping("/api/autocode/entity")
public class EntityController extends BaseController {

    @Autowired
    private IEntityService entityService;
    
    /**
     * 查询
     */
    @ApiOperation(value="实体配置-查询")
    @RequestMapping(value="/list", method = RequestMethod.GET)
    public ResDTO<ResEntityQueryDTO> listEntity(ReqEntityQueryDTO reqInfo,PageQueryDTO page) throws Exception{
        ResEntityQueryDTO data = entityService.queryEntityList(reqInfo,page);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @ApiOperation(value="实体配置-详情")
    @RequestMapping(value="/detail", method = RequestMethod.GET)
    public ResDTO<ResEntityDetailDTO> detailEntity(ReqEntityDetailDTO reqInfo) throws Exception{
        ResEntityDetailDTO data = entityService.queryEntityDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @ApiOperation(value="实体配置-新增")
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public ResDTO<ResEntityAddDTO> addEntity(@RequestBody ReqDTO<ReqEntityAddDTO> reqInfo) throws Exception{
        ResEntityAddDTO data = entityService.insertEntityInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @ApiOperation(value="实体配置-编辑")
    @RequestMapping(value="/edit", method = RequestMethod.POST)
    public ResDTO<ResEntityEditDTO> editEntity(@RequestBody ReqDTO<ReqEntityEditDTO> reqInfo) throws Exception{
        ResEntityEditDTO data = entityService.updateEntityInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="实体配置-删除")
    @RequestMapping(value="/del", method = RequestMethod.POST)
    public ResDTO<ResEntityDelDTO> delEntity(@RequestBody ReqDTO<ReqEntityDelDTO> reqInfo) throws Exception{
        ResEntityDelDTO data = entityService.deleteEntityInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @ApiOperation(value="实体配置-状态更新")
    @RequestMapping(value="/state", method = RequestMethod.POST)
    public ResDTO<ResEntityStateDTO> stateEntity(@RequestBody ReqDTO<ReqEntityStateDTO> reqInfo) throws Exception{
        ResEntityStateDTO data = entityService.updateEntityState(reqInfo);
        return successDATA(data); 
    }
    
    
}